package org.example.myleet.rosalind.prtm;

import org.example.myleet.rosalind.utils.AminoAcidMassReader;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Map;

public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.printProteinMass("SKADYEK");
        solution.printProteinMass("RDSTDTPSGRDHSGWQIFQRFFDSRIQFNDVDGIHDYVGHQTENYDGNVVIDVLITFHYSPLWDLAVNQPIWVFHNAMDCWHSNQGPHNLQPNTDGKPIIQYPDWYMMEFYMHQPHKMNPMHSGMSEYLVGSAMIPRGGEYNSKQIRAQYHESVYYLEKAEDYKAYSKKDHREAVSCTIRLQKWKIWMPQTYYSMWKLPYAFCFFKAFFKYRYCYCETGGLLCIWHEQQQPFMSMNTGRSTWYSKEHCRIFNHVTYPMYFNAWQACFMMPQDGPFWKSGSWLPWSQNMHEQYSNTFQEWTFPAVIHTVWKAQQSFKWYNEGCNFTVMMRIILVVWKAPTIMMCHNSSHAIEQGLHFVYAFCVKTLFDVEPMRMPGYSEKLLPEKMIKCYNSRIAGQAHNDWLCNLHHPSDTYVPAMKSRNTKQPKHYMPGMCKASNIPDNIKWECCNKFTSPQQTLQKHLMALCAVFKSPHQNIIKCIMPDVWMGYFSLFISYYDVEPHWYYVMQRCLKAHMYHKRLTSPEIWRYHDNSPFIGCIFVVRVQIAAWRDHGTCPVIHNYVYCDLPDNFWYKPIHHIDWGRDLCLAGNLISMTRLWCAVHDLRMPPELTYNFIYDCALMHCYIDQTITWSYVWNPHASNTPMMDGPFMRRNVKEYDWMQTHHQRSVCKLDMPLDAMQSCQNKRYRSGGWLMRHYRGTGMKIPTWAENEMKCSIGPRKQEVRESSYKNYWTRRCVPDKVPGVRNISMLLQMPTSIFAEMRIVQFQYVHYDPMWVLQTGEAEFEFHCDSDKSGSKEDGGGIVDQFAHITKIKNEGLVSLHCCPFLRHKESQRQMIVHCLHKKDADGSIHCEACQVNGNLYHGSDFWNYYGSTVYFKCETWHNGCLWAHGEGHMRIKRGSNYYDGCAHPYCHIDIVHWPNCMCCRPQAFLDFRYYKCPCYPEHCEKWYCFDRTRSMTFAACKAVGCSINVNGIACGHYSVITPQHTTCMERQPKWNHEDEFFINLT");
    }

    public void printProteinMass(String protein) {
        Map<String, BigDecimal> aminoAcidMapMass = AminoAcidMassReader.getAminoAcidMassMap();
        BigDecimal res = BigDecimal.ZERO;
        for (int i = 0; i < protein.length(); ++i) {
            String aa = protein.substring(i, i + 1);
            res = res.add(aminoAcidMapMass.get(aa));
        }
        System.out.println(res.setScale(3, RoundingMode.HALF_UP));
    }
}
